<?php
ob_start() ;

if(!isset($_SESSION))
{
    session_start();
}

require_once('../../../../include/inc_config.php') ;
    
$iIdentifiantContrat  = array_key_exists('idcontrat', $_SESSION) ? $_SESSION['idcontrat'] : 0 ;
$iIdentifiantContrat  = getHttpVar('Identifiant_contrat', $_oDefault) ;
$iIdentifiantPersonne = getHttpVar('Identifiant_personne', 0) ;

mysql_select_db($database_microassur, $microassur);
$requete = mysql_query("select * from role where Identifiant_contrat='" . $iIdentifiantContrat . "' and role.Type_role='S'");

if($requete && mysql_num_rows($requete)){$reponse=mysql_fetch_array($requete);$idpers=$reponse['Identifiant_personne'];}
else $idpers=-1;
//echo "*****************".$_SESSION['idcontrat'];
$query_rs = "select * from rib where rib.Etat_rib='A' and  rib.Identifiant_personne='".$idpers."'";
$rs = mysql_query($query_rs, $microassur) or die(mysql_error()) ;
$row_rs = mysql_fetch_assoc($rs);
//echo $totalRows_rs = mysql_num_rows($rs);

$colname_rs_pers = "-1";
if ($iIdentifiantPersonne) {
  $colname_rs_pers = $iIdentifiantPersonne ;
}
mysql_select_db($database_microassur, $microassur);
$query_rs_pers = sprintf("SELECT * FROM personne WHERE Identifiant_personne = %s", GetSQLValueString($colname_rs_pers, "int"));
$rs_pers = mysql_query($query_rs_pers, $microassur) or die(mysql_error());
$row_rs_pers = mysql_fetch_assoc($rs_pers);
$totalRows_rs_pers = mysql_num_rows($rs_pers);
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>RIB</title>
<link rel="stylesheet" type="text/css" href="../../../../css/main.css" />
            <link rel="stylesheet" type="text/css" href="list.css" />
			<!--[if IE 7]>
            	<link rel="stylesheet" type="text/css" href="../../../../css/ie7.css" />
            	<link rel="stylesheet" type="text/css" href="form_ie7.css" />
            <![endif]-->
            
<script language="Javascript">
            <!--
                function modifier(choix){
                    var suppAct = document.getElementById("suppAct");
					var ratAct = document.getElementById("ratAct");
					var modAct = document.getElementById("modAct");
                    //modifAct.href = 'saisierib1.php?Identifiant_personne=<?php //echo $row_rs['Identifiant_rib']; ?>&Identifiant_rib=' + choix ;
                    suppAct.href = 'supprimerrib.php?Identifiant_personne=<?php echo $iIdentifiantPersonne ; ?>&Identifiant_contrat=<?php echo $iIdentifiantContrat ; ?>&Identifiant_rib=' + choix ;
                    ratAct.href = 'rattacherrib.php?Identifiant_personne=<?php echo $iIdentifiantPersonne ; ?>&Identifiant_contrat=<?php echo $iIdentifiantContrat ; ?>&Identifiant_rib=' + choix ;
                    modAct.href = 'saisierib.php?Identifiant_personne=<?php echo $iIdentifiantPersonne ; ?>&Identifiant_contrat=<?php echo $iIdentifiantContrat ; ?>&Identifiant_rib=' + choix ;
                }
            //-->
            </script></head>
<body>
<div id="sf_menu1">
	<h3>Production <?php //echo nomPersonne($database_microassur, $microassur, $iIdentifiantPersonne) ?></h3>

<?php
	if(isset($_GET['rattacher']) && $_GET['rattacher']==0)$message=colorer("Problème rattachement du RIB au contrat, contacter la DSI ","false");
	elseif(isset($_GET['rattacher']) && $_GET['rattacher']==1) $message=colorer("","true");
	
	if(isset($_GET['supp']))
	{
		if($_GET['supp']=='success')
			$message = colorer("Le RIB a été supprimé","false");
		else if($_GET['supp']=='err')
			$message = colorer("Erreur lors de la suppression du RIB","false");
	}
	
	if(isset($message) && !empty($message)){
		echo $message;
	}
	$nommodule="Modification administrative";
	$nommodule2="Liste des RIB";
	//$nom_module_saisie="Ecran saisie";
?>
</div>
<div class="cleared"></div>

<div class="corps1">
	<div class="imgleft"></div>
	<div class="imgmiddle">
		<div class="btn">
        	<span class="btnleft"></span>
            <span class="btnmiddle">
            	<h5><?php echo $nommodule; ?></h5>
            </span><span class="btnright"></span>
        </div>
		<div class="btn1">
        	<span class="btnleft"></span>
            <span class="btnmiddle">
            	<h5><?php echo $nommodule2; ?></h5>
            </span><span class="btnright"></span>
        </div>
		<div class="cleared"></div>
<table class="tab_liste">
 <tr id="niv1">
 	<td class="td1"></td>
    <td class="td2">BANQUE</td>
    <td class="td3">GUICHET</td>
    <td>COMPTE</td>
    <td class="td5">CLE RIB</td></table>  
 <div class="content_table bright">
  <table class="tab_list">
  <?php $i=1; if(mysql_num_rows($rs)>0) {
  do {
   ?>
    <tr <?php if($i%2==0) echo 'class="colorligne"'; ?>>
    <td class="td1">
      	<input onClick="modifier(this.value);" type="radio" name="choix" id="choix" value="<?php echo $row_rs['Identifiant_rib']; ?>" />
      </td>
      <td class="td2"><?php echo $row_rs['Code_banque_rib']; ?></td>
      <td class="td3"><?php echo $row_rs['Code_guichet_rib']; ?></td>
      <td><?php echo $row_rs['Numero_compte_rib']; ?></td>
      <td class="td5"><?php echo $row_rs['Cle_rib']; ?></td>
    </tr>
    <?php $i++;} while ($row_rs = mysql_fetch_assoc($rs)); }?>
</table>
</div>
<div id="buttonright"><span class="btleft"></span><span class="btmiddle"><a href="saisierib.php?Identifiant_personne=<?php echo $iIdentifiantPersonne ; ?>&Identifiant_contrat=<?php echo $iIdentifiantContrat ; ?>">Créer</a></span><span class="btright"></span></div>
<div id="buttonright"><span class="btleft"></span><span class="btmiddle"><a id="modAct" href="#">Modifier</a></span><span class="btright"></span></div>						
<div id="buttonright"><span class="btleft"></span><span class="btmiddle"><a id="ratAct" href="#">Rattacher</a></span><span class="btright"></span></div>
<div id="buttonright"><span class="btleft"></span><span class="btmiddle"><a id="suppAct" href="#">Supprimer</a></span><span class="btright"></span></div>

</div>
	<div class="imgright"></div>
	<div class="cleared"></div>

<div class="bt1">
	<a href="../index.php?Identifiant_personne=<?php echo $iIdentifiantPersonne ; ?>&Identifiant_contrat=<?php echo $iIdentifiantContrat ; ?>&rib=1">
    	<span class="btleft"></span>
        <span class="btmiddle">Retour</span>
        <span class="btright"></span>
    </a>
</div>

  </div>
</body>
</html>
<?php
mysql_free_result($rs);

mysql_free_result($rs_pers);
?>
<?php ob_end_flush();?>